package com.example.login_captcha_2.controller;


import com.example.login_captcha_2.dto.UserLoginDTO;
import com.example.login_captcha_2.restful.JsonResult;
import com.example.login_captcha_2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/user", produces="application/json;charset=utf-8")
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 登录认证
     * @param loginDTO UserLoginDTO
     * @return JsonResult<Void>
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public JsonResult<Void> login(@Validated UserLoginDTO loginDTO) {
        userService.login(loginDTO);

        return JsonResult.success();
    }

}